package cn.edu.scujcc.dpl;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

import com.andremion.music.MusicCoverView;

public class yinguiActivity extends AppCompatActivity {
    private MusicCoverView mCoverView;
    private ImageView playImage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.yingui);
        ImageView btn = findViewById(R.id.yg1);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent();
                it.setClass(yinguiActivity.this, Trackdebugging.class);
                startActivity(it);
            }
        });
        ImageView btn1 = findViewById(R.id.back);
        btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent();
                it.setClass(yinguiActivity.this, createActivity.class);
                startActivity(it);
            }
        });
        ImageView btn2 = findViewById(R.id.next);
        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent it = new Intent();
                it.setClass(yinguiActivity.this, fabuActivity.class);
                startActivity(it);
            }
        });
        mCoverView = findViewById(R.id.yg1);
        playImage = findViewById(R.id.kais);
        playImage.setOnClickListener(v -> {
            if (mCoverView.isRunning()) {  //判断转动，如果转动则停止
                mCoverView.stop();
            } else {
                mCoverView.morph();
            }
        });

        mCoverView.setCallbacks(new MusicCoverView.Callbacks() {

            @Override
            public void onMorphEnd(MusicCoverView coverView) {
                Log.d("TEST", "原型吗？" + (MusicCoverView.SHAPE_CIRCLE == coverView.getShape()));
                if (MusicCoverView.SHAPE_CIRCLE == coverView.getShape()) {
                    coverView.start();
                }
            }

            @Override
            public void onRotateEnd(MusicCoverView coverView) {
                coverView.morph();
            }
        });

        }
    }
